package com.example.task1.ui.AllService.life;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.LifeWeatherBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class LifeWeatherDayAdapter extends BaseAdapter<LifeWeatherBean.DataDTO.WeatherListDTO> {

    private List<LifeWeatherBean.DataDTO.WeatherListDTO> mData = new ArrayList<>();
    private Context context;
    private TextView tvDay;
    private TextView tvLabel;
    private TextView tvWeather;
    private TextView tvMin;
    private TextView tvMax;


    public LifeWeatherDayAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<LifeWeatherBean.DataDTO.WeatherListDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.lifeweatherdaylist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<LifeWeatherBean.DataDTO.WeatherListDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, LifeWeatherBean.DataDTO.WeatherListDTO date) {
        tvWeather.setText(date.getWeather());
        tvDay.setText(date.getDay());
        tvLabel.setText(date.getLabel());
        tvMax.setText(date.getMinTemperature());
        tvMin.setText(date.getMaxTemperature());
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View view) {

        tvDay = (TextView) view.findViewById(R.id.tv_day);
        tvLabel = (TextView) view.findViewById(R.id.tv_label);
        tvWeather = (TextView) view.findViewById(R.id.tv_weather);
        tvMin = (TextView) view.findViewById(R.id.tv_min);
        tvMax = (TextView) view.findViewById(R.id.tv_max);
    }
}
